﻿using ECO.Admin.Core.EntityCore;
using SqlSugar;
using System;
using System.Collections.Generic;

namespace ECO.Admin.Core.Entities.System
{
    [SugarTable("SysUser", TableDescription = "用户表")]
    public class SysUser : EntityBase<int>
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 用户邮箱
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string Email { get; set; }

        /// <summary>
        /// 用户密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string Phone { get; set; }

        /// <summary>
        /// 用户状态
        /// </summary>
        public bool Status { get; set; } = true;

        /// <summary>
        /// 加密 盐
        /// </summary>
        public string Salt { get; set; }

        /// <summary>
        /// 账号是否被锁
        /// </summary>
        public bool IsLock { get; set; } = false;

        /// <summary>
        /// 账号解锁时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime UnlockTime { get; set; }

        /// <summary>
        /// 登录失败次数
        /// </summary>
        public int FaildCount { get; set; } = 0;

        /// <summary>
        /// 角色
        /// </summary>
        [Navigate(typeof(SysUserRoleMapping), nameof(SysUserRoleMapping.UserId), nameof(SysUserRoleMapping.RoleId))]//注意顺序
        public List<SysRole> Roles { get; set; }
    }
}
